package com.production.CoursePlatform.service;

import com.production.CoursePlatform.entity.CurriculumResources;
import com.production.CoursePlatform.mapper.CurriculumResourcesMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CurriculumResourcesService {

    @Autowired
    private CurriculumResourcesMapper curriculumResourcesMapper;

    // 增加
    public boolean saveCurriculumResource(CurriculumResources resource) {
        return curriculumResourcesMapper.insertWithoutRsID(resource) > 0;
    }

    // 删除
    public boolean deleteCurriculumResourceBYrsID(int rsID) {
        return curriculumResourcesMapper.deleteById(rsID) > 0;
    }

    // 修改
    public boolean updateCurriculumResource(CurriculumResources resource) {
        return curriculumResourcesMapper.updateById(resource) > 0;
    }

    // 查询单个资源
    public CurriculumResources getCurriculumResourceById(int rsID) {
        return curriculumResourcesMapper.selectById(rsID);
    }

    // 按照ctID查询资源
    public List<CurriculumResources> getAllCurriculumResources(int ctID) {
        return curriculumResourcesMapper.selectByCtID(ctID);
    }
}
